# 修复所有Java文件中的log.info语法错误

$javaFiles = Get-ChildItem -Path "src\main\java" -Filter "*.java" -Recurse
$fixedCount = 0

foreach ($file in $javaFiles) {
    try {
        $content = Get-Content $file.FullName -Raw -Encoding UTF8
        $originalContent = $content
        
        # 移除所有包含log.info("@的行
        $content = $content -replace '\s*log\.info\("@[^"]*"\);?\s*\r?\n', ""
        
        # 移除孤立的log.info语句
        $content = $content -replace '\s*log\.info\([^)]*\);?\s*(?=\r?\n)', ""
        
        if ($content -ne $originalContent) {
            [System.IO.File]::WriteAllText($file.FullName, $content, [System.Text.UTF8Encoding]::new($false))
            Write-Host "Fixed: $($file.Name)"
            $fixedCount++
        }
    }
    catch {
        Write-Host "Error processing file: $($file.Name) - $($_.Exception.Message)"
    }
}

Write-Host "Fixed $fixedCount files total."